/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package caa.struts.login.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Ketsaraporn
 */
public class LoginForm extends ActionForm {

    private String UserName = "";
    private String UserPassword = "";
    private String error;

    /**
     * @return the UserName
     */
    public String getUserName() {
        return UserName;
    }

    /**
     * @param UserName the UserName to set
     */
    public void setUserName(String UserName) {
        this.UserName = UserName;
    }

    /**
     * @return the UserPassword
     */
    public String getUserPassword() {
        return UserPassword;
    }

    /**
     * @param UserPassword the UserPassword to set
     */
    public void setUserPassword(String UserPassword) {
        this.UserPassword = UserPassword;
    }

    /**
     * @return the error
     */
    public String getError() {
        return error;
    }

    /**
     * @param error the error to set
     */
    public void setError() {
        this.error = "<span style='color:red'>กรุณากรอกข้อมูลให้ครบถ้วน</span>";        
    }

//    @Override
//    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
//        ActionErrors errors = new ActionErrors();
//
//        if (getUserName() == null || getUserName().equalsIgnoreCase("")) {
//            errors.add("username", new ActionMessage("error.username.required"));
//        }
//        if (getUserPassword() == null || getUserPassword().equalsIgnoreCase("")) {
//            errors.add("userpassword", new ActionMessage("error.userpassword.required"));
//        }
//        return errors;
//    }

    @Override
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        this.UserName = "";
        this.UserPassword = "";
    }
}
